package com.efuture.androidmvvmdemo.listener

import com.efuture.androidmvvmdemo.databinding.ActivityMainBinding
import com.efuture.androidmvvmdemo.view.adapter.HomeDataAdapter
import com.efuture.androidmvvmdemo.view.ui.MainActivity
import com.efuture.androidmvvmdemo.viewmodel.MainViewModel
import com.efuture.netrequestdemo.bean.Project

/**
 *@description:主页面事件处理
 * @author: zhaoshanshan
 * @date: 2022/3/27 2:28 下午
 */
class MainListener(val mainViewModel: MainViewModel,val activity: MainActivity) {

     fun getHomeData(cid:String) {

         mainViewModel.getHomeData(cid)
    }
    fun dealWithHomeDataResult(homeData: Project,homeDataAdapter: HomeDataAdapter){

        if(null!=homeData&&homeData.errorCode==0){
            homeDataAdapter.updateList(homeData.data.datas)
        }else{
            if(null!=homeData&&null!=homeData.errorMsg){
                ToastUtils.showShort(homeData.errorMsg)
            }else{
                ToastUtils.showShort("获取主页数据失败")
            }
        }

    }
}